<?php
defined('IN_MAIN') or exit('Invalid Access!');

function build_stockist_state($country, $selected, $name, $extra=""){
/*
This function will build a select box consisting of all the states of a given country code of all the stockists within that country
*/

global $vars;
$db=$vars["db"];

$r_state[0]="";
$r_state_d[""]=__("Please select a state");
$t=@mysql_num_rows($r=mysql_query("select distinct(state) from $db->stockists where country='$country' and status='normal' order by state"));
for($i=0;$i<$t;$i++){
 $state=mysql_result($r, $i);
 $r_state[($i+1)]=nhtmlentities($state);
 $r_state_d[nhtmlentities($state)]=$state;
}
return build_select($r_state, $r_state_d, $selected, $name, $extra);
}
?>